<template>
  <el-form :model="formData" label-width="80px">
    <el-form-item label="姓名" prop="name">
      <el-input v-model="formData.name" placeholder="请输入姓名"></el-input>
    </el-form-item>
    <el-form-item label="性别" prop="gender">
      <el-radio-group v-model="formData.gender">
        <el-radio label="男">男</el-radio>
        <el-radio label="女">女</el-radio>
      </el-radio-group>
    </el-form-item>
    <el-form-item label="年龄" prop="age">
      <el-input-number v-model="formData.age" :min="1" :max="100"></el-input-number>
    </el-form-item>
    <el-form-item label="爱好" prop="hobbies">
      <el-checkbox-group v-model="formData.hobbies">
        <el-checkbox label="篮球">篮球</el-checkbox>
        <el-checkbox label="足球">足球</el-checkbox>
        <el-checkbox label="游泳">游泳</el-checkbox>
      </el-checkbox-group>
    </el-form-item>
    <el-form-item label="自我介绍" prop="introduction">
      <el-input type="textarea" v-model="formData.introduction" placeholder="请输入自我介绍"></el-input>
    </el-form-item>
    <el-form-item>
      <el-button type="primary" @click="submitForm">提交</el-button>
    </el-form-item>
  </el-form>
</template>

<script setup>
import { ref } from 'vue';
import axios from "@/util/request";
const formData = ref({
  name: '',
  gender: '男',
  age: 18,
  hobbies: [],
  introduction: ''
});

const submitForm = () => {
  let url = "/item";
  axios.post(url,formData.value).then(function (result){
    console.log(result)
  })

};
</script>
